package edu.yuhf.aspect;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AspectService {
	
	private Logger log=Logger.getLogger(AspectService.class);
	
	@Pointcut("execution(* edu.yuhf.dao.EmpJdbcDaoImpl.checkNameAndPassword(..))")
	public void aspectMethod(){}
	

	@Around("aspectMethod()")
	public boolean getTime(ProceedingJoinPoint jp) throws Throwable{
		long timeStart=System.currentTimeMillis();
		log.debug("get time start。。。");
		Object[] args=jp.getArgs();
		boolean result=(boolean) jp.proceed(args);
		long timeEnd=System.currentTimeMillis();
		long time=timeEnd-timeStart;
		log.debug("get time end...and total time:"+time);
		return result;
	}
}
